




var _oSCUConst =
{

sEntityMode:					"entity",
sAttributeMode:					"attribute",
sRelationshipMode:				"relationship",
sShowUsageUrlFormat:			"/tools/systemcustomization/showUsage.aspx?mode={0}",
iUsageDialogWidth:				600,
iUsageDialogHeight:				400
};
var _oSCUErrorCodes =
{
sAccessDenied:					"0x80070005"
};



var _oTags =
{
activities				: "activities",
assign					: "assign",
associatedentity		: "associatedentity",
attribute				: "attribute",
attributeid				: "attributeid",
attributemap			: "attributemap",
attributeschemaname		: "attributeschemaname",
cascading				: "cascading",
defaultvalue			: "defaultvalue",
Delete					: "delete",
description				: "description",
displayarea				: "displayarea",
displayareas			: "displayareas",
displayed				: "displayed",
displayname				: "displayname",
duplicatecheck          : "duplicatecheck",
entity					: "entity",
entities				: "entities",
entityid				: "entityid",
entitymapid				: "entitymapid",
format					: "format",
id						: "id",
length					: "length",
maxvalue				: "maxvalue",
merge					: "merge",
minvalue				: "minvalue",
name					: "name",
notes					: "notes",
offline					: "offline",
ownershiptype			: "ownershiptype",
pluralname				: "pluralname",
precision				: "precision",
publish					: "publish",
referencedentityname	: "referencedentityname",
referencedinstancename	: "referencedinstancename",
referencingentityname	: "referencingentityname",
referencinginstancename	: "referencinginstancename",
relationship			: "relationship",
relationshipid			: "relationshipid",
reparent				: "reparent",
reqlevel				: "reqlevel",
richclient				: "richclient",
schemaname				: "schemaname",
searchable				: "searchable",
share					: "share",
singularname			: "singularname",
type					: "type",
imemode					: "imemode",
yomiof					: "yomiof",
sourceattributename		: "sourceattributename",
targetattributename		: "targetattributename",
unshare					: "unshare",
associatedmenu			: "associatedmenu",
displayoption			: "displayoption",
displayarea				: "displayarea",
navpaneorder			: "navpaneorder",
customlabel				: "customlabel",
currententity			: "currententity",
otherentity				: "otherentity",
entityname				: "entityname",
entityrelationshipid	: "entityrelationshipid",
manytomany				: "manytomany",
associatedmenuotherentity : "associatedmenuotherentity",
currententityname		: "currententityname",
otherentityname			: "otherentityname",
intersectentityname		: "intersectentityname"
};










function createXmlDoc(sRootName)
{
return loadXmlDoc("<" + sRootName + "></" + sRootName + ">");
}





function loadXmlDoc(sXml)
{
var oXml = loadXmlDocument(sXml);
return oXml.documentElement;
}




function convertXmlDocToString(oXml)
{
var sUnicodeXml = oXml.xml;
var sUTF8CompatibleXml = new StringBuilder();
for (var i = 0; i < sUnicodeXml.length; i++)
{
var code = sUnicodeXml.charCodeAt(i);
var code2 = 0;
if (i+1 < sUnicodeXml.length)
{
code2 = sUnicodeXml.charCodeAt(i+1);
}
if (code < 0x80)
{
sUTF8CompatibleXml.Append(sUnicodeXml.charAt(i));
}
else if (code >= 0xD800 && code <= 0xDBFF && code2 >= 0xDC00 && code2 <= 0xDFFF)
{

sUTF8CompatibleXml.Append("&#x" + (((code - 0xD800) * 0x400) + (code2 & 0x03FF) + 0x10000).toString(16) + ";");
i++;
}
else if (code >= 0xD800 && code <= 0xDFFF)
{


sUTF8CompatibleXml.Append("&#xFFFD;");
}
else
{
sUTF8CompatibleXml.Append("&#x" + code.toString(16) + ";");
}
}
return sUTF8CompatibleXml.ToString();
}





function addXmlNode(oParentNode, sChildNodeName)
{
var oChildNode = oParentNode.ownerDocument.createElement(sChildNodeName);
oParentNode.appendChild(oChildNode);
return oChildNode;
}





function addTextXmlNode(oParentNode, sChildNodeName, oChildNodeValue)
{
var oChildNode = null;

if (oChildNodeValue != null)
{
oChildNode = addXmlNode(oParentNode, sChildNodeName);
oChildNode.text = oChildNodeValue.toString();
}

return oChildNode;
}





function addXmlAttribute(oParentNode, sAttributeName, oAttributeValue)
{
if (oAttributeValue != null)
{
var oAttribute;
oAttribute = oParentNode.ownerDocument.createAttribute(sAttributeName);
oAttribute.value = oAttributeValue.toString();
oParentNode.attributes.setNamedItem(oAttribute);
}
}





function addControlDataValue(oParentNode, sChildNodeName, oControl)
{
addControlDataValue(oParentNode, sChildNodeName, oControl, false);
}





function addControlDataValue(oParentNode, sChildNodeName, oControl, bAddEvenIfDisabled)
{
if (!oControl.Disabled || bAddEvenIfDisabled)
{
addTextXmlNode(oParentNode, sChildNodeName, oControl.DataValue);
}
}





function addControlDataValueAsAttribute(oParentNode, sChildNodeName, oControl)
{
if (!oControl.Disabled)
{
addXmlAttribute(oParentNode, sChildNodeName, oControl.DataValue);
}
}





function addXmlString(oParentNode, sXml)
{
var oNode = null;

if (sXml != null)
{
oNode = loadXmlDoc(sXml);
oParentNode.appendChild(oNode.cloneNode(true));
}
return oNode;
}





var _oRemoteCommandContext =
{
oCommand			: null,
fCallback			: null,
oCallbackParams		: null,
bMessageShown		: false
};
function executeRemoteCommand(oCommand, sActionMessage, fCallback, oCallbackParams)
{

_oRemoteCommandContext.oCommand = oCommand;

_oRemoteCommandContext.fCallback = fCallback;
_oRemoteCommandContext.oCallbackParams = oCallbackParams;

if (sActionMessage != null)
{
DisplayActionMsg(sActionMessage, 400, 150);
_oRemoteCommandContext.bMessageShown = true;
}
else
{
_oRemoteCommandContext.bMessageShown = false;
}

window.setTimeout(executeRemoteCommandInternal, 100);
}
function executeRemoteCommandInternal()
{

var oResult = _oRemoteCommandContext.oCommand.Execute();


var bMessageShown = _oRemoteCommandContext.bMessageShown;
var bHideMessage = true;
var fCallback = _oRemoteCommandContext.fCallback;
var oCallbackParams = _oRemoteCommandContext.oCallbackParams;
_oRemoteCommandContext = new Object();


if (fCallback != null)
{
bHideMessage = fCallback(oResult, oCallbackParams);
}

if (bMessageShown && bHideMessage)
{
HideActionMsg();
}

}





function showUsage(sMode, oUsage)
{

var sUrl = prependOrgName(formatString(_oSCUConst.sShowUsageUrlFormat, sMode));
openStdDlg(sUrl, oUsage, _oSCUConst.iUsageDialogWidth, _oSCUConst.iUsageDialogHeight);
}





function showError(sErrorCode)
{
openErrorDlg(sErrorCode);
}





var KEY_ESC	= 27;
var KEY_F12	= 123;
var KEY_S	= 83;
function ProcessKeyDown()
{
with (event)
{
switch (keyCode)
{
case KEY_ESC:
window.close();
return false;
case KEY_F12:
if( shiftKey )
{

if (window._saveEnabled == true)
{
_save();
}
return false;
}
break;
case KEY_S:
if (ctrlKey)
{


if (altKey && altLeft && USER_LANGUAGE_CODE == 1045)
{
return true;
}
if (shiftKey)
{

if (window._saveAndNewEnabled == true)
{
_saveandnew();
}
}
else
{

if (window._saveEnabled == true)
{
_save();
}
}
return false;
}
else if (altKey)
{

if (window._saveAndCloseEnabled == true)
{
_saveandclose();
}
return false;
}
break;
}
}
}
